package edu.ccut.saturn.manager.logger.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import edu.ccut.saturn.component.DefaultComponent;
import edu.ccut.saturn.component.ILogger;
import edu.ccut.saturn.component.IParameterContext;

public class ILoggerToMap extends DefaultComponent {
	@SuppressWarnings("unchecked")
	@Override
	public void execute(IParameterContext parameterContext) throws Exception {
		
		List<ILogger> list = (ArrayList<ILogger>)parameterContext.getParameterValue(0);
		
		List<Map<String, String>> result = new ArrayList<Map<String,String>>();
		
		if(list != null){
			for(ILogger iLogger : list){
				Map<String, String> map = new HashMap<String, String>();
				map.put("key", iLogger.getKey());
				map.put("level", iLogger.getLevel());
				result.add(map);
			}
		}
		
		parameterContext.setParameter(0, result);
	}
}